<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserAbilitiesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_abilities', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id');
            $table->unsignedTinyInteger('breaking_ice')->default(0)->comment('破冰力 0-100');
            $table->unsignedTinyInteger('empathy')->default(0)->comment('共情度 0-100');
            $table->unsignedTinyInteger('conversation_flow')->default(0)->comment('推进技巧 0-100');
            $table->boolean('is_baseline')->default(false)->comment('是否为基准测试结果');
            $table->timestamp('created_at')->useCurrent();
            
            // 外键约束
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            
            // 索引
            $table->index(['user_id']);
            $table->index(['created_at']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_abilities');
    }
}